﻿@model ListViewModel<CommonSearchValues, IQueryable<QizSession>>
@{
    ViewBag.Title = "常规随访单查询";

    var itemList = new List<SelectListItem>();
    var subjects = ViewBag.Subjects as IEnumerable<QizSubject>;
    foreach (var sub in subjects.Where(v => v.ParentQizSubject == null && (v.SubjectType == null || v.SubjectType == "常规随访单") && v.StatusID == "100").OrderByDescending(v => v.SortIdx))
    {
        itemList.Add(new SelectListItem() { Text = "[" + sub.Title + "]", Value = sub.ID });
        if (sub.SubQizSubjects.Count > 0)
        {
            //v.StatusID != "104" &&
            foreach (var subSubj in sub.SubQizSubjects.Where(v => v.StatusID != "103").OrderByDescending(v => v.SortIdx))
            {
                itemList.Add(new SelectListItem() { Value = subSubj.ID, Text = " └─" + subSubj.Title });
            }
        }
    };
}
<style type="text/css">
    select {
        font-size: 9pt;
    }
</style>
@using (Ajax.BeginForm("QizSessionList", new { IsView = false }, new AjaxOptions { HttpMethod = "Post", LoadingElementId = "OnLoadingSpan", UpdateTargetId = "main", OnFailure = "OnSiteError" }))
{<div class="toolbox">
    <div class="icons icons-add ">
        常规随访单查询 
        &nbsp; &nbsp;<a href="javascript:void(0)" onclick="$('#advanced-search').toggle();">[切换高级查询...]</a>
    </div>
    @*<fieldset>
        <legend>
            <div class="catalog-title">
                常规随访单查询
            </div>
        </legend>*@
        @Html.Action("SFReport")
        @Html.HiddenFor(m => Model.PageSize)
        @*@Html.Hidden("PageIdx", 0, new { id = "qspidx" })*@
        <input type="hidden" name="PageIdx" id="qspidx" value="0" />
        <div class="width" style="background-color: #f8f8f8; line-height: 22px;">
            <table class="noborder small-input">
                <tr>
                    <td align="right">随访单名称：</td>
                    <td align="left">
                        @Html.DropDownListFor(m => m.SearchFrom.V1, new SelectList(itemList, "Value", "Text", Model.SearchFrom.V1), "全部")
                        @Html.DropDownListFor(m => m.SearchTo.V1, new List<SelectListItem>()
                                {
                                        new SelectListItem(){ Value = "1",Text = "主随访和检查单" },
                                        new SelectListItem(){ Value = "2",Text = "只显示检查单" }
                                }, "只显示主随访")
                    </td>
                    <td align="right">性别：</td>
                    <td align="left">
                        @Html.DropDownListFor(m => m.SearchFrom.V5, new List<SelectListItem>()
                    {
                        new SelectListItem(){ Value = "男",Text = "男" },
                            new SelectListItem(){ Value = "女",Text = "女" }
                    }, "全部")
                    </td>
                    <td align="right">主管医生：</td>
                    <td align="left">@Html.DropDownListFor(m => m.SearchFrom.V4, new SelectList(ViewBag.Users, "UserID", "UserName", Model.SearchFrom.V4), "全部")</td>
                    <td align="right">填报人：</td>
                    <td align="left">@Html.EditorFor(m => m.SearchFrom.V2)</td>
                    <td align="right">@Helpers.SubmitButton("查询", "qssubmit")</td>
                </tr>
            </table>
            <table class="noborder small-input">
                <tr>
                    
                    <td align="right">&nbsp;&nbsp;&nbsp;&nbsp;随访类型：</td>
                    <td align="left">@Html.EditorFor(m => m.SearchFrom.V0)</td>
                    <td align="right">填报质量：</td>
                    <td align="left">@Html.EditorFor(m => m.SearchTo.V0)</td>
                    @*<td align="right"><a id="btn-advanced" href="#" onclick="diplayAdvanced(this);return false;">高级选项</a></td>*@
                </tr>
            </table>
            <table id="advanced-search" class="noborder" style="display: none;">
                <tr>
                    <td align="right">&nbsp;&nbsp;&nbsp;出院诊断：</td>
                    <td align="left">@Html.EditorFor(m => m.SearchTo.V4)</td>
                    <td align="right">出院时间：</td>
                    <td align="left">
                        @Html.EditorFor(m => m.SearchFrom.V6, "DateTimeStr")
                        至 @Html.EditorFor(m => m.SearchTo.V6, "DateTimeStr")
                    </td>
                </tr>
                <tr>
                    <td align="right">&nbsp;&nbsp;&nbsp;手术名称：</td>
                    <td align="left">@Html.EditorFor(m => m.SearchTo.V5)</td>
                    <td align="right">随访时间：</td>
                    <td align="left">
                        @Html.EditorFor(m => m.SearchFrom.V3, "DateTimeStr")
                        至 @Html.EditorFor(m => m.SearchTo.V3, "DateTimeStr")
                    </td>
                </tr>
            </table>
        </div>
    @*</fieldset>*@
    </div>
}
<table class="width">
    <tr>
        <th>常规随访名称
        </th>
        <th>填报人
        </th>
        <th>性别
        </th>
        <th>随访类型
        </th>
        <th>主管医生
        </th>
        <th>出院日期
        </th>
        <th>填报时间
        </th>
        <th>检查时间
        </th>
        <th>指标异常
        </th>
        <th>新
        </th>
        <th>附件
        </th>
        <th>填报质量
        </th>
        <th>操作
        </th>
    </tr>
    @{int dColor = 0;}
    @foreach (var item in Model.Data)
    {
        <tr class="tr-backColor@(dColor++ % 2)" style="@(item.SessionAutoEvaluation == "异常" ? "color:red" : "")">
            <td title="@item.QizSubject.Title">@Html.FixStrSuffix(item.QizSubject.Title, 12)
            </td>
            <td>
                @if (item.Recuper == null)
                {
                    <div class="Error">
                        Error:ID=@item.ID,RecID=@item.RecuperID
                    </div>
                }
                else
                {
                    @Ajax.ActionLink(item.aspnet_Users.UserName, "RecuperEnHospEdit", new { ID = item.Recuper.RecuperID, _t = DateTime.Now.Ticks, _ReadOnly = false }, new AjaxOptions() { LoadingElementId = "OnLoadingSpan", UpdateTargetId = "dialogbox", OnComplete = "showDialog('患者信息');", HttpMethod = "Get", InsertionMode = InsertionMode.Replace, OnFailure = "OnSiteError" })
                }
            </td>
            <td>@Html.DisplayFor(model => item.aspnet_Users.Gender)
            </td>
            <td title="@item.Recuper.SuiFangLeiXing">@Html.FixStrSuffix(item.Recuper.SuiFangLeiXing, 8)
            </td>
            <td>@Html.DisplayFor(model => item.Recuper.Doctor.UserName)
            </td>
            <td>
                @if (item.Recuper.DeHospDay != DateTime.MinValue)
                {
                    @Html.DisplayFor(model => item.Recuper.DeHospDay)
                }
            </td>
            <td>@item.CreationTime.ToString("yyyy/MM/dd")
            </td>
            <td>
                @item.Timemark.ToString("yyyy/MM/dd")
            </td>
            <td>@(item.SessionAutoEvaluation == "异常" ? item.SessionAutoEvaluation : string.Empty)
            </td>
            <td id="NT_@(item.ID)" align="center">
                @if (item.UnRead)
                {
                    @Ajax.ActionLink("★", "SetQizSessionReaded", new { ID = item.ID }, new AjaxOptions()
               {
                   UpdateTargetId = "NT_" + item.ID,
                   InsertionMode = InsertionMode.Replace,
                   HttpMethod = "Get",
                   //OnSuccess = "OnS",
                   OnFailure = "OnSiteError"
               }, new { style = "color:#f19149;text-decoration:none;" })
                }
            </td>
            <td>
                @(item.QizSessionDetails.Where(v => v.QizSubjectDefine.QizItem.Type == "206" && v.UserValue != null).Count().ToString())
                @*.Where(v => v.UserValue != null && v.UserValue != string.Empty && v.QizSubjectDefine.QizItem.TypeRef.OptionValue == "6")*@
            </td>
            <td>
                @Html.DisplayFor(model => item.TianBaoZhiLiang)
            </td>
            <td>
                @Html.ActionLink("[详细]", "QizSessionEdit", new { ID = item.ID, PreviewOnly = true, _newpage = "true" }, new { target = "_blank" })
                @Html.ActionLink("[补录]", "QizSessionEdit", new { ID = item.ID, IsDebug = true, PreviewOnly = false, _newpage = "true" }, new { target = "_blank" })
                @Html.ActionLink("[历史]", "RecuperReport", new { qizSubjectID = item.QizSubjectID, recuperID = item.Recuper.RecuperID, pageIndex = 0 }, new { target = "_blank" })
                @Ajax.ActionLink("[留言]", "SentSmsToSessionRecuper", new { reciver = item.Recuper.RecuperID }, new AjaxOptions() { LoadingElementId = "OnLoadingSpan", UpdateTargetId = "dialogbox", OnComplete = "showDialog('短信留言');", HttpMethod = "Get", InsertionMode = InsertionMode.Replace, OnFailure = "OnSiteError" })
            </td>
        </tr>
    }
</table>
<table class="width noborder">
    <tr>
        <td>
            @Html.Partial("Pagger", new PaggerViewModel { Act = "QizSessinList", PageIdx = Model.PageIdx, PageCount = Model.PageCount, ItemCount = Model.ItemCount })
        </td>
        <td align="right">
            @using (Html.BeginForm("QizSessionListExport", null, new { }, FormMethod.Post, new { target = "_blank", onsubmit = "alert('根据导出数据的多少，可能会有需要很长时间，导出过程请耐心等待...。');" }))
            {
                var currentFilter = new ListViewModel<CommonSearchValues, string>() { SearchFrom = Model.SearchFrom, SearchTo = Model.SearchTo };
                <span style="display: none;">
                    @Html.Hidden("CurrentFilterOfJson", System.Web.Helpers.Json.Encode(currentFilter))
                    <input type="submit" name="ExportType" value="exportsession" id="exportsession" />
                    <input type="submit" name="ExportType" value="exportdetail" id="exportdetail" />
                </span>
                <a href="#QizSessionListExport" onclick="$('#exportsession').click()">导出基本随访数据</a> <span>&nbsp;
                    &nbsp;</span>  <a href="#QizSessionListExport" onclick="$('#exportdetail').click()">导出详细填报指标</a>
            }
        </td>
    </tr>
</table>
@Html.Partial("TrHilighter")
@{
    var sflxs = "'" + string.Join("','", SiteUser.Department.DepartmentProfiles.Where(v => v.SettingKey.Equals("SuiFangLeiXing", StringComparison.OrdinalIgnoreCase)).Select(v => v.SettingValue).Distinct().ToArray()) + "'";
    var tbzls = "'" + string.Join("','", SiteUser.Department.DepartmentProfiles.Where(v => v.SettingKey.Equals("TianBaoZhiLiang",StringComparison.OrdinalIgnoreCase)).Select(v => v.SettingValue).Distinct().ToArray()) + "'";
    
}
<script type="text/javascript">
    function diplayAdvanced(el) {
        if ($(el).text() == '高级选项') {
            $('#advanced-search').show();
            $(el).text('收起');
        } else {
            $('#advanced-search').hide();
            $(el).text('高级选项');
        }
    };
    $(function () {
        if ($('#SearchTo_V4').val() != '' || $('#SearchTo_V5').val() != ''
            || $('input[name="SearchFrom.V6"]').val() != '' || $('input[name="SearchTo.V6"]').val() != ''
            || $('input[name="SearchFrom.V3"]').val() != '' || $('input[name="SearchTo.V3"]').val() != '') {
            $('#advanced-search').show();
            $('#btn-advanced').text('收起');
        }
        $("#SearchFrom_V0").select2({ maximumSelectionSize: 1, tags: [ @Html.Raw(sflxs)] });
        $("#SearchTo_V0").select2({ maximumSelectionSize: 1, tags: [ @Html.Raw(tbzls)] });
    });
</script>
